Count of subarrays having sum equal to its length
Given an array arr[] of size N, the task is to find the number of subarrays having the sum of its elements equal to the number of elements in it....
read more
Longest subarray having maximum sum
Given an array arr[] containing n integers. The problem is to find the length of the subarray having maximum sum. If there exists two or more subarrays with maximum sum then print the length of the longest subarray.Examples:...
read more
Maximum sum bitonic subarray
Given an array containing n numbers. The problem is to find the maximum sum bitonic subarray. A bitonic subarray is a subarray in which elements are first increasing and then decreasing. A strictly increasing or strictly decreasing subarray is also considered a bitonic subarray. Time Complexity of O(n) is required....
read more
Count of ways to form N digit number div by 3 with no adjacent duplicates
Given integer N, the task is to count the number of ways( modulo 109 + 7) to create an N digit number from digits 1 to 9 such that adjacent digits are different and the number is divisible by 3....
read more
Minimum cost to delete characters from String A to remove any subsequence as String B
Given two strings A and B of size N and M respectively, where B is a sub-sequence of A and an array arr[] of size N, where arr[i] is the cost to delete ith character from string A. The task is to find the minimum cost to delete characters from A such that after deletion no subsequence of A is the same as B....
read more
Maximum Tip Calculator
Rahul and Ankit are the only two waiters in the Royal Restaurant. Today, the restaurant received N orders. The amount of tips may differ when handled by different waiters and given as arrays A[] and B[] such that if Rahul takes the ith Order, he would be tipped A[i] rupees, and if Ankit takes this order, the tip would be B[i] rupees....
read more
Maximum K-digit number possible from subsequences of two given arrays
Given two arrays arr1[] and arr2[] of length M and N consisting of digits [0, 9] representing two numbers and an integer K(K ? M + N), the task is to find the maximum K-digit number possible by selecting subsequences from the given arrays such that the relative order of the digits is the same as in the given array....
read more
Find Minimum Removals for Valid Block Sequences
Given an array arr[] of size n, a sequence is called valid if it is in series of blocks where each starting element denotes the length of the block i.e first comes the length of the block then its element, for example the sequence [3 3 4 5 2 6 1], here the blocks are [3 3 4 5] and [2 6 1]. In one operation you can remove any one element of the array. The task is to determine the minimum number of operations required to make the array a valid sequence....
read more
Remove minimum elements from either side such that 2*min becomes more than max | Set 2
Given an unsorted array, trim the array such that twice of minimum is greater than the maximum in the trimmed array. Elements should be removed from either end of the array. The number of removals should be minimum....
read more
Fixed Coins for Target Sum with Constraint K
Given a set of coin denominations the total number of coins (n) and a target amount (target), the task is to determine if it’s possible to make change, for the target amount using k coins. You have one supply of each coin denomination....
read more
Largest integers with sum of setbits at most K
Given an array of integer nums[] and a positive integer K, the task is to find the maximum number of integers that can be selected from the array such that the sum of the number of 1s in their binary representation is at most K....
read more
Number of sub-sequence such that it has one consecutive element with difference less than or equal to 1
Given an array arr[] of N elements. The task is to find the number of sub-sequences which have at least two consecutive elements such that absolute difference between them is ? 1....
read more